package com.chengzhi.netty.handler;

import com.chengzhi.nettycommoms.disruptor.MessageConsumer;
import com.chengzhi.nettycommoms.dto.NettyMessageWapper;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ServerMessageConsumer extends MessageConsumer {

    public ServerMessageConsumer(String consumerId) {
        super(consumerId);
    }

    @Override
    public void onEvent(NettyMessageWapper nettyMessageWapper) throws Exception {
        log.info(consumerId + " paramter ----------" + nettyMessageWapper.getNettyMessage().toString());
        Channel channel = nettyMessageWapper.getCtx().channel();
        nettyMessageWapper.getNettyMessage().setMsg("server id --------" + nettyMessageWapper.getNettyMessage().getId());
        channel.writeAndFlush(nettyMessageWapper.getNettyMessage());
    }
}
